home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / DiceSource / lib / amiga / resident.c < prev    next >
C/C++ Source or Header  |  1997-09-09  |  2KB  |  76 lines

  1.  
  2. /*
  3.  *  RESIDENT.C
  4.  *
  5.  *    (c)Copyright 1992-1997 Obvious Implementations Corp.  Redistribution and
  6.  *    use is allowed under the terms of the DICE-LICENSE FILE,
  7.  *    DICE-LICENSE.TXT.
  8.  *
  9.  */
  10.  
  11. #define SysBase_DECLARED
  12. #define DOSBase_DECLARED
  13.  
  14. #include <exec/types.h>
  15. #include <exec/execbase.h>
  16. #include <exec/ports.h>
  17. #include <exec/memory.h>
  18. #include <libraries/dos.h>
  19. #include <libraries/dosextens.h>
  20. #include <lib/bcpl.h>
  21. #include <lib/misc.h>
  22. #include <clib/exec_protos.h>
  23. #include <string.h>
  24.  
  25. typedef struct DosLibrary   DosLibrary;
  26. typedef struct RootNode     RootNode;
  27. typedef struct DosInfo        DosInfo;
  28. typedef struct CommandLineInterface CLI;
  29.  
  30. typedef struct MsgPort        MsgPort;
  31. typedef struct Message        Message;
  32. typedef struct Task        Task;
  33. typedef struct Process        Process;
  34.  
  35. typedef struct SegNode {
  36.     BPTR    NextEntry;
  37.     LONG    UseCount;
  38.     BPTR    SegPtr;
  39.     unsigned char    SegName[32];
  40. } SegNode;
  41.  
  42. extern struct ExecBase *SysBase;
  43. extern DosLibrary *DOSBase;
  44.  
  45. /*
  46.  *  Search the resident list for the specified command returning its segment.
  47.  *  case insensitive (for OS 1.3 only)
  48.  */
  49.  
  50. long
  51. _SearchResident(cmd)
  52. char *cmd;
  53. {
  54.     SegNode *node;
  55.     DosInfo *di = BTOC(((RootNode *)DOSBase->dl_Root)->rn_Info, DosInfo);
  56.     short len = strlen(cmd);
  57.  
  58.     Forbid();
  59.     for (node = BTOC(di->di_NetHand, SegNode); node; node = BTOC(node->NextEntry, SegNode)) {
  60.     if (node->SegName[0] == len) {
  61.         short i;
  62.         for (i = 0; i < len; ++i) {
  63.         if ((node->SegName[1+i] ^ cmd[i]) & ~0x20)
  64.             break;
  65.         }
  66.         if (i == len) {
  67.         Permit();
  68.         return((long)node->SegPtr);
  69.         }
  70.     }
  71.     }
  72.     Permit();
  73.     return(0);
  74. }
  75.  
  76.